﻿using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    /// <summary>
    /// 询价记录表
    /// </summary>
    public class InquiryDal : BaseDal<EAInquiry>
    {
        public override string tablename
        {
            get { return "EAInquiry"; }
        }

        public override Dictionary<string, bool> PKName
        {
            get
            {
                Dictionary<string, bool> dic = new Dictionary<string, bool>();
                dic.Add("inquiry_Id", true);
                return dic;
            }
        }

        /// <summary>
        /// 询价添加
        /// </summary>
        /// <param name="Inquiry"></param>
        /// <returns></returns>
        public bool InquiryAdd(EAInquiry Inquiry)
        {
            string sql = Common.Common.ToAddSql<EAInquiry>(Inquiry, tablename, PKName);
            return Common.DBHelp.GetExecuteNonQuery(sql);
        }

        /// <summary>
        /// 询价显示
        /// </summary>
        /// <returns></returns>
        public List<EAInquiry> InquiryList()
        {
            string sql = Common.Common.GetTable<EAInquiry>(tablename);
            DataTable dt = Common.DBHelp.GetDataSet(sql);

            List<EAInquiry> eAInquiry = new List<EAInquiry>();
            foreach (DataRow item in dt.Rows)
            {
                EAInquiry eAInquiry1 = new EAInquiry();
                foreach (var i in eAInquiry1.GetType().GetProperties())
                {
                    i.SetValue(eAInquiry1, item[i.Name]);
                }
                eAInquiry.Add(eAInquiry1);
            }
            return eAInquiry;
        }
    }
}
